﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DefineButtonSoundTag : Tag
    {
        public ushort ButtonId
        {
            get;
            protected set;
        }

        public ushort ButtonSoundChar0
        {
            get;
            protected set;
        }

        public SoundInfo ButtonSoundInfo0
        {
            get;
            protected set;
        }

        public ushort ButtonSoundChar1
        {
            get;
            protected set;
        }

        public SoundInfo ButtonSoundInfo1
        {
            get;
            protected set;
        }

        public ushort ButtonSoundChar2
        {
            get;
            protected set;
        }

        public SoundInfo ButtonSoundInfo2
        {
            get;
            protected set;
        }

        public ushort ButtonSoundChar3
        {
            get;
            protected set;
        }

        public SoundInfo ButtonSoundInfo3
        {
            get;
            protected set;
        }

        public DefineButtonSoundTag(int len, int offset)
            : base(TagCodes.DefineButtonSound, len, offset)
        {
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            ButtonId = reader.ReadUInt16();

            ButtonSoundChar0 = reader.ReadUInt16();

            if (ButtonSoundChar0 != 0)
            {
                ButtonSoundInfo0 = new SoundInfo();
                ButtonSoundInfo0.SwfDeserialize(reader);
            }

            ButtonSoundChar1 = reader.ReadUInt16();

            if (ButtonSoundChar1 != 0)
            {
                ButtonSoundInfo1 = new SoundInfo();
                ButtonSoundInfo1.SwfDeserialize(reader);
            }

            ButtonSoundChar2 = reader.ReadUInt16();

            if (ButtonSoundChar2 != 0)
            {
                ButtonSoundInfo2 = new SoundInfo();
                ButtonSoundInfo2.SwfDeserialize(reader);
            }

            ButtonSoundChar3 = reader.ReadUInt16();

            if (ButtonSoundChar3 != 0)
            {
                ButtonSoundInfo3 = new SoundInfo();
                ButtonSoundInfo3.SwfDeserialize(reader);
            }
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
